package dominio;

import junit.framework.TestCase;

public class CalculadoraTest extends TestCase {

	Calculadora cal;
	
	//@Before
	public void setUp() throws Exception {
		cal=new Calculadora();
	}

	//@After
	public void tearDown() throws Exception {
	}

	//@Test
	public void testSuma() {
		
		double x=5.5,y=4;
		assertEquals(cal.suma(x, y),9.5);
		x=-5.5;
		y=-4;
		assertEquals(cal.suma(x, y),-9.5);
		x=0;
		y=-4;
		assertEquals(cal.suma(x, y),-4.0);
		x=0;
		y=4;
		assertEquals(cal.suma(x, y),4.0);
		x=0;
		y=0;
		assertEquals(cal.suma(x, y),0.0);
		x=3;
		y=-2;
		assertEquals(cal.suma(x,y),1.0);
	}

	//@Test
	public void testResta() {
		
		double x=5.5,y=4;
		assertEquals(cal.resta(x, y),1.5);
		x=-5.5;
		y=-4;
		assertEquals(cal.resta(x, y),-1.5);
		x=0;
		y=-4;
		assertEquals(cal.resta(x, y),+4.0);
		x=0;
		y=4;
		assertEquals(cal.resta(x, y),-4.0);
		x=0;
		y=0;
		assertEquals(cal.resta(x, y),0.0);
		x=3;
		y=-2;
		assertEquals(cal.resta(x,y),5.0);
	}

	//@Test
	public void testMultiplica() {
		double x=5.5,y=4;
		assertEquals(cal.multiplica(x, y),22.0);
		x=-5.5;
		y=-4;
		assertEquals(cal.multiplica(x, y),22.0);
		x=0;
		y=-4;
		assertEquals(cal.multiplica(x, y),-0.0);
		x=0;
		y=4;
		assertEquals(cal.multiplica(x, y),0.0);
		x=0;
		y=0;
		assertEquals(cal.multiplica(x, y),0.0);
		x=3;
		y=-2;
		assertEquals(cal.multiplica(x,y),-6.0);
		
	}

	//@Test
	public void testDivide() {
		double x=5.5,y=4;
		assertEquals(cal.divide(x, y),1.375);
		x=-5.5;
		y=-4;
		assertEquals(cal.divide(x, y),1.375);
		x=0;
		y=-4;
		assertEquals(cal.divide(x, y),-0.0);
		x=0;
		y=4;
		assertEquals(cal.divide(x, y),0.0);
		x=4;
		y=-2;
		assertEquals(cal.divide(x,y),-2.0);
		x=1;
		y=0;
		try{
			cal.divide(x,y);
		}catch (ArithmeticException E)
		{
			assertEquals(1, 1);
		}
	}

}
